(function($){
	var inputs,loginForm, loginFormValid,login ={} ;
	
	
	login.init = function(){
		inputs = $('input'),loginForm=$("#loginForm");
		loginFormValid=loginForm.validate({
			errorElement : 'span',  
	        errorClass : 'help-block',
	        focusInvalid : true,  
	        rules : {  
	        	userName : {  
	        		required : true ,
	                minlength: 5,
	                maxlength: 18
	            },  
	            password : {  
	            	required : true ,
	                minlength: 5,
	                maxlength: 18
	            } 
	        }, 
	        messages : {  
	        	userName : {  
	                required  : "用户名不能为空",
	                minlength : "用户名长度不小于5"
	            },
	            password : {
	            	required  : "密码不能为空" ,
	                minlength : "密码长度不小于5"
	                /*,maxlength:"登录密码不应超过18位"*/
	            }
	        }, 
			highlight : function(element) {  
	            $(element).closest('.form-group').addClass('has-error');  
	        },
	        success : function(label) {  
	            label.closest('.form-group').removeClass('has-error');  
	            label.remove();  
	        },
	        errorPlacement : function(error, element) {  
	            element.parent('div').append(error);  
	        },
	        submitHandler : function(form) {
	        	window.location.href = base_url+"/index"
				return false;
			}
		});
			
		login.bindEvent();
	};
	
	login.bindEvent = function(){
		
		inputs.iCheck({
	      checkboxClass: 'icheckbox_square-blue',
	      radioClass: 'iradio_square-blue',
	      increaseArea: '20%' /* optional */
	    });
		
	};
	
	
	window.login = login;
	$(function(){
		login.init();
	});
	
})(jQuery);






